<?php

namespace app\controllers;

class ReportController extends AuthController
{
    public $currentHeader = 'header-report';
    public $currentNav = 'report-nav';
    public $pageTitle = '';

    public function init() {
        parent::init();
        // $this->adnetworkOnLabel = $this->toJson([]);
        // $this->labelOnCampaign = $this->toJson([]);
        // $this->campaignOnSolution = $this->toJson([]);
    }

    public function actionCampaignReport() {
        $this->pageTitle = $this->t('report', 'Data Report');
        $costFilter = 'true';
        if (in_array($this->S('user_rank'), ['agent', 'advertiser'])) $costFilter = '';
        $this->costFilter = $costFilter;
        list($labelOnCampaign, $campaignOnSolution, $solutionOnCreative) = $this->service->getAdNetworkLableCampaignSolutionLevel();
        $this->labelOnCampaign = $labelOnCampaign;
        $this->campaignOnSolution = $campaignOnSolution;
        $this->solutionOnCreative = $solutionOnCreative;
        $this->filter = $this->isAllowedSeeShows();
        return $this->show();
    }

    public function actionGetAllReportData() {
        $reports = $this->service->getReportData();
        $this->jsonReturn($reports);
    }

    public function actionGetAppReportData()
    {
        $appDayReport = $this->service->getAppDayReport();
        $this->jsonReturn($appDayReport);
    }

    public function actionExportReport() {
        $filter = $this->isAllowedSeeShows();
        $this->service->exportReportData($filter);
    }
}//end
